//
//  ContactVC.m
//  phmall
//
//  Created by admin on 2017/12/20.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "ContactVC.h"

@interface ContactVC ()<UITableViewDelegate,UITableViewDataSource>
@property(strong,nonatomic)UITableView *myTableview;
@end

@implementation ContactVC
-(void)rightBarAction{
//    self.hidesBottomBarWhenPushed=YES;
//    SendMessageVC *evaluate=[[SendMessageVC alloc]init];
//    [self.navigationController pushViewController:evaluate animated:YES];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navBarBgAlpha=@"1.0";
    //    // 改变NavBar顶层View的颜色
    self.navigationController.navigationBar.barTintColor =  [UIColor whiteColor];
    
    UIBarButtonItem* leftBar=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(leftBarAction)];
    self.navigationItem.leftBarButtonItem=leftBar;
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"联系详情";
    
    [self.view addSubview:self.myTableview];
    [self.myTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(0);
        make.left.right.equalTo(self.view).priorityHigh();
        make.bottom.equalTo(self.view).with.offset(0).priorityHigh();
    }];
    
    UIView *headerView=[UIView new];
    headerView.backgroundColor=[UIColor groupTableViewBackgroundColor];
    
    UIView *addresserView=[[UIView alloc]init];
    addresserView.backgroundColor=[UIColor whiteColor];
    [headerView addSubview:addresserView];
    [addresserView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(10);
        make.left.right.offset(0);
        make.height.offset(44);
    }];
    
    UILabel *addresserLabel=[[UILabel alloc]init];
    [addresserView addSubview:addresserLabel];
    addresserLabel.text=@"联系人:";
    addresserLabel.font=[UIFont systemFontOfSize:15];
    [addresserLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(10);
    }];
    
    UILabel *addresser=[[UILabel alloc]init];
    addresser.text=@"发件人ID";
    addresser.textAlignment=NSTextAlignmentRight;
    addresser.textColor=[UIColor colorWithHexString:@"#adadad"];
    addresser.font=[UIFont systemFontOfSize:15];
    [addresserView addSubview:addresser];
    [addresser mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(addresserLabel.mas_right).offset(10).priorityHigh();
        make.right.offset(-10).priorityHigh();
        make.centerY.offset(0);
    }];
    
    UIView *recipientsView=[[UIView alloc]init];
    recipientsView.backgroundColor=[UIColor whiteColor];
    [headerView addSubview:recipientsView];
    [recipientsView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(addresserView.mas_bottom).offset(1);
        make.left.right.offset(0);
        make.height.offset(44);
    }];
    
    UILabel *recipientsLabel=[[UILabel alloc]init];
    [recipientsView addSubview:recipientsLabel];
    recipientsLabel.text=@"联系方式:";
    recipientsLabel.font=[UIFont systemFontOfSize:15];
    [recipientsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(10);
    }];
    
    UIButton *phone=[UIButton buttonWithType:UIButtonTypeCustom];
    [phone setImage:[UIImage imageNamed:@"联系电话"] forState:UIControlStateNormal];
    [recipientsView addSubview:phone];
    [phone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.centerY.offset(0);
    }];
    
    UIButton *note=[UIButton buttonWithType:UIButtonTypeCustom];
    [note setImage:[UIImage imageNamed:@"PhChat-1"] forState:UIControlStateNormal];
    [recipientsView addSubview:note];
    [note mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(phone.mas_left).offset(-10);
        make.centerY.offset(0);
    }];
    
    UIView *messageView=[[UIView alloc]init];
    messageView.backgroundColor=[UIColor whiteColor];
    [headerView addSubview:messageView];
    [messageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(recipientsView.mas_bottom).offset(1);
        make.left.right.offset(0);
        make.bottom.offset(0);
    }];
    
    UILabel *messageLabel=[[UILabel alloc]init];
    [messageView addSubview:messageLabel];
    messageLabel.text=@"联系地址:";
    messageLabel.font=[UIFont systemFontOfSize:15];
    [messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(13);
        make.left.offset(10);
    }];
    
    CGSize detailSize = [messageLabel.text sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(200, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
    UILabel *message=[[UILabel alloc]init];
    message.textColor=[UIColor colorWithHexString:@"#adadad"];
    message.text=@"内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容内容";
    message.numberOfLines=0;
    message.font=[UIFont systemFontOfSize:15];
    [messageView addSubview:message];
    [message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(SCREEN_WIDTH-detailSize.width-30);
        make.right.offset(-10);
        make.top.offset(13).priorityHigh();
        make.bottom.offset(-13).priorityHigh();
    }];
    
    CGFloat height = [headerView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    CGRect frame = headerView.bounds;
    frame.size.height = height;
    headerView.frame = frame;
    [self.myTableview setTableHeaderView:headerView];
    // Do any additional setup after loading the view.
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 0;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 1;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"newCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;;
    }
    cell.opaque=YES;
    cell.layer.drawsAsynchronously=YES;
    cell.layer.rasterizationScale=[UIScreen mainScreen].scale;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //分割线补全
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//MARK:-GETTER
- (UITableView *)myTableview{
    if (!_myTableview) {
        _myTableview = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _myTableview.delegate = self;
        _myTableview.dataSource = self;
        _myTableview.backgroundColor=[UIColor groupTableViewBackgroundColor];
        _myTableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        _myTableview.showsVerticalScrollIndicator=NO;
        //        _myTableview.emptyDataSetSource=self;
        //        _myTableview.emptyDataSetDelegate=self;
        _myTableview.scrollEnabled = YES;
    }
    return _myTableview;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
